package com.yizn.learn.concurrent;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author yisl
 * @create 2020-04-03 16:08
 */
public class HashmapTest {

    public static void main(String[] args) {
        HashmapThread thread1 = new HashmapThread();
        HashmapThread thread2 = new HashmapThread();
        HashmapThread thread5 = new HashmapThread();
        HashmapThread thread3 = new HashmapThread();
        HashmapThread thread4 = new HashmapThread();

        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();
        thread5.start();

    }
}

 class HashmapThread extends Thread{
    private static Map<Integer, Integer> staticMap = new HashMap();
    private static AtomicInteger ai = new AtomicInteger();

    @Override
    public void run(){
        while (ai.get()<1000000){
            staticMap.put(ai.get(),ai.get());
            ai.incrementAndGet();
        }

    }
}
